import configparser
class Config:
    __config_file = r"F:\Project\PythonProject\Study01\data\config.ini"
    def __init__(self):
        c= configparser.ConfigParser()
        c.read(Config.__config_file)
        self.__server=c.get("database","server")
        self.__dbname=c.get("database","dbname")
        self.__username=c.get("database","user")
        self.__password=c.get("database","password")
        self.__port=c.get("database","port")

    @property
    def server(self):
        return self.__server
    @property
    def dbname(self):
        return self.__dbname
    @property
    def username(self):
        return self.__username
    @property
    def password(self):
        return self.__password
    @property
    def port(self):
        return self.__port
 # 单例设计
config=Config()